package org.example.utils;

import java.util.Random;

public class TranslationUtils {

    private static final String ENGLISH = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    private static final int CHINESE_MIN = 0x4E00;
    private static final int CHINESE_MAX = 0x9FFF;

    public static String generate(int length) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            if (random.nextBoolean()) { // 随机决定是中文还是英文
                int codePoint = CHINESE_MIN + random.nextInt(CHINESE_MAX - CHINESE_MIN + 1);
                sb.appendCodePoint(codePoint);
            } else {
                sb.append(ENGLISH.charAt(random.nextInt(ENGLISH.length())));
            }
        }
        return sb.toString();
    }


    public static String getTranslation(){
        Random random = new Random();
        int length = random.nextInt(1000) + 30;
        return generate(length); // 例如："欢迎使用中文"
    }

}
